package com.grass.appointment.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidx.p013lv.base.bean.CityEntity;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.grass.appointment.C2694R;
import java.util.List;

public class HotCityListAdapter extends BaseAdapter {
    private List<CityEntity> cityEntities;
    private Context context;
    private ItemClickListener itemClickListener;

    public void setItemClickListener(ItemClickListener itemClickListener2) {
        this.itemClickListener = itemClickListener2;
    }

    public HotCityListAdapter(Context context2) {
        this.context = context2;
    }

    public void setCityEntities(List<CityEntity> list) {
        this.cityEntities = list;
        notifyDataSetChanged();
    }

    public int getCount() {
        List<CityEntity> list = this.cityEntities;
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    public Object getItem(int i) {
        List<CityEntity> list = this.cityEntities;
        if (list == null) {
            return null;
        }
        return list.get(i);
    }

    public long getItemId(int i) {
        if (this.cityEntities == null) {
            return 0;
        }
        return (long) i;
    }

    public View getView(final int i, View view, ViewGroup viewGroup) {
        View view2;
        ViewHolder viewHolder;
        if (view == null) {
            viewHolder = new ViewHolder();
            view2 = View.inflate(this.context, C2694R.C2699layout.city_list_grid_item_layout, null);
            viewHolder.cityNameTv = (TextView) view2.findViewById(C2694R.C2697id.city_list_grid_item_name_tv);
            view2.setTag(viewHolder);
        } else {
            view2 = view;
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.cityNameTv.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.appointment.adapter.HotCityListAdapter.View$OnClickListenerC27681 */

            public void onClick(View view) {
                if (HotCityListAdapter.this.itemClickListener != null) {
                    HotCityListAdapter.this.itemClickListener.onItemClick(view, i);
                }
            }
        });
        viewHolder.cityNameTv.setText(this.cityEntities.get(i).getName());
        return view2;
    }

    private static class ViewHolder {
        TextView cityNameTv;

        private ViewHolder() {
        }
    }
}
